Copyright ã1992 by Scott Hess.  All Rights Reserved.

OSC Tricks

It will be tempting for those who are familiar with xterm to output the title for the window directly using sequences similar to the examples, and to ignore the Directory-setting sequence entirely.  Try to resist this temptation!  Setting Directory to the current directory is much more useful.  By inserting a `%{Directory}' string in window titles, you get the current directory in the titlebar without extra effort - and Stuart can use Directory for a number of unrelated features (see Features/Directory).  It is better to use the title-setting sequences to set the window title once on startup, and then leave it alone.  For instance, in your shell startup file you might do:

osc -title "${HOST}:%{Directory} (%{Columns}x%{Lines})"

And then enter the appropriate codes to keep your Directory preference up-to-date (see Examples).

Another suggestion was brought to my attention by Alex Blakemore (alex@cs.umd.edu), one of the Stuart2.4 beta testers.  If you have your hostname in your Stuart titlebar, and log into another system using telnet, your startup files on the remote system can update your titlebar with the remote hostname as demonstrated above.  But, when you log off the remote system, the titlebar will not revert to the original hostname.  The solution is to use aliases for the commands used to remotely log into a site.  Under tcsh, you would use something like:

# Set up cwdcmd to keep your Directory current.
alias cwdcmd 'osc'
# Retitle the window and update Directory.
alias retitle 'osc -title "${HOST}:%{Directory}" ; cwdcmd'

# Run a command and fix the titlebar on exit.
alias telnet 'telnet \!* ; retitle'
alias rlogin 'rlogin \!* -8 ; retitle'
alias kermit 'kermit \!* ; retitle'

You may wish to include appropriate aliases for each command you routinely use for remote logins.  This trick also works for any other programs which might change your titlebar, such as a shell or an editor.